#ifndef _CCYBERSPACESTATE_H_
#define _CCYBERSPACESTATE_H_

#include "IGameState.h"
#include "Messaging/IListener.h"
#include "CEffect.h"
#include "Game Objects/CCamera.h"
#include "CMap.h"
#include "CAI.h"
#include "Game Objects/CMinimap.h"
#include "static.h"
#include "Game Objects/CNode.h"
class CBaseMessage;

class CCyberSpaceState : public IGameState, public IListener
{
private:
	CCyberSpaceState(void);
	CCyberSpaceState(const CCyberSpaceState&);
	CCyberSpaceState& operator=(const CCyberSpaceState&);
	~CCyberSpaceState(void);

	// Player object
	CPlayer* m_pPlayer;

	// Camera object
	CCamera* m_pCamera;

	// Pointer to the singletons
	CSGD_TextureManager*				m_pTM;
	CSGD_Direct3D*						m_pD3D;

	// Test variables
	int m_nBulletsOnScreen;

	// Asset variables
	int m_nMusicID;
	int m_nHUDID;
	int m_nHealthID;
	int m_nPistolSelectID;
	int m_nShotgunSelectID;
	int m_nRocketSelectID;
	int m_nBackgroundID;
	int m_nLoadingID;
	int m_nReticleID;

	// ID for the audio logs
	int m_nAudioLogID;

	// Notification flags
	bool m_bPistolAmmo;
	bool m_bShotAmmo;
	bool m_bRocketAmmo;

	// Notification timers
	float m_fPistolTimer;
	float m_fShotgunTimer;
	float m_fRocketTimer;
	

	//grenade Timer
	float m_fGrenadeTimer;

	// The current room that the player is in
	int m_nCurrRoom;

	// The current weapon that the player is using
	int m_nCurrWeapon;

	// The current grenade that the player has equipped
	int m_nCurrGrenade;

	// The number of nodes to display on the map
	int m_nNumNodes;
	
	// List of effects
	CEffect effects;

	// Player's health
	float m_fPlayerHealth;
	float m_fPlayerMaxHealth;
	// Is the node that the AI is trying to take flashing?
	float m_fFlashTimer;
	bool m_bIsFlashing;

	//map object
	CMap* map; 

	//AI object
	CAi AI;

	// Mini-map object
	CMinimap m_cmMap;

	// Is the state loading?
	bool m_bIsLoading;
	// How much is loaded
	int m_nPercentLoaded;

	// Value for speed upgrade increase
	float m_fSpeedUpgrade;

	void playervalid(CMap* themap);


	//static stuff
	CDamageglitch statics;

	//Animation Stuff
	int PistolDownAnimationID;
	int PistolUpAnimationID;
	int PistolLeftAnimationID;
	
	
	int ShotgunDownAnimationID;
	int ShotgunUpAnimationID;
	int ShotgunLeftAnimationID;
	

	int RocketDownAnimationID;
	int RocketUpAnimationID;
	int RocketLeftAnimationID;
	int RocketShootID;

	int PistolShootDownAnimID;
	int PistolShootLeftAnimID;
	int PistolShootUpAnimID;
	
	int ShotgunShootDownAnimID;
	int ShotgunShootLeftAnimID;
	int ShotgunShootUpAnimID;
	
	int RocketShootDownAnimID;
	int RocketShootLeftAnimID;
	int RocketShootUpAnimID;

	int ThrowGrenadeUpID;
	int ThrowGrenadeLeftID;
	int ThrowGrenadeDownID;

	bool Movingup, Movingdown, Movingleft, Movingright;
	bool ShootingUp, ShootingDown, ShootingLeft, ShootingRight;
	bool GrenadeDown, GrenadeRight, GrenadeUp, GrenadeLeft;

	int CursorID;
	
public:
	enum roomNames { OFFICE, SECURITY, SNACK, SEC_CONTROL, 
					MAIN_CONTROL, POD, MAXROOMS };

	enum weaponNames { PISTOL, SHOTGUN, ROCKETS, MAXWEAPON };

	enum grenadeNames { EX_GRENADE, FW_GRENADE };

	void setmap(CMap* themap){map = themap;} 

	static CCyberSpaceState* GetInstance(void);

	CNode* getnode();

	void Enter(void);

	// Display loading screen
	void DisplayLoading(void);

	bool Input(void);
	void Update(float fElapsedTime);
	void Render(void);
	void Exit(void);

	static void MessageProc(CBaseMessage* pMsg);

	float DegreeToRadian(float angle);

	/////////////////////////////////////////////////////
	//	Function	:	Accessors
	//	Purpose		:	To get the specified type.
	/////////////////////////////////////////////////////
	
	// Get the player		
	CPlayer*	GetPlayer()				{ return m_pPlayer; }
	int			GetNumBullets()			{ return m_nBulletsOnScreen; }
	int			GetCurrentRoom()		{ return m_nCurrRoom; }
	int			GetCurrentWeapon()		{ return m_nCurrWeapon; }
	int			GetCurrentGrenade()		{ return m_nCurrGrenade; }
	float		GetHealth()				{ return m_fPlayerHealth; }
	float		GetMaxHealth()			{ return m_fPlayerMaxHealth; }
	CMap*		GetMap()				{ return map; }
	CAi			GetAI()					{ return AI; }
	bool		GetFlashing()			{ return m_bIsFlashing; }
	bool		GetIsMovingUp()			{return Movingup;}
	bool		GetIsMovingDown()		{return Movingdown;}
	bool		GetIsMovingLeft()		{return Movingleft;}
	bool		GetIsMovingRight()		{return Movingright;}
	bool		GetLoading()			{ return m_bIsLoading; }
	
	/////////////////////////////////////////////////////
	//	Function	:	Modifiers
	//	Purpose		:	To set the specified type.
	/////////////////////////////////////////////////////

	// Set the player.
	void SetPlayer(CPlayer* pPlayer)			{ m_pPlayer = pPlayer; }
	void SetNumBullets(int nBulletsOnScreen)	{ m_nBulletsOnScreen = nBulletsOnScreen; }
	void SetHealth(float fHealth) { m_fPlayerHealth = fHealth; }
	void SetMaxHealth(float fMaxHealth) { m_fPlayerMaxHealth = fMaxHealth; }

	void SetPistolFlag(bool bValue) { m_bPistolAmmo = bValue; }
	void SetShotFlag(bool bValue) { m_bShotAmmo = bValue; }
	void SetRocketFlag(bool bValue) { m_bRocketAmmo = bValue; }
	// Set the current room the player is in
	void SetCurrentRoom(int nRoom) { m_nCurrRoom = nRoom; }

	// Listen for events
	void HandleEvent(CEvent* pEvent);
};

#endif